<h1>TableIndex</h1>

<p>TableIndex is used with a Push action to push a reference to an entry in a table 
of literals onto the stack. The value is can then be retrieved from the table and 
used in a subsequent calculation. The data type was extended in Flash 6 to support 
tables of up to 65535 strings.</p>

<table>

<tr>
<th>Field</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">type</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>Identifies the data type for decoding by the Push action. For Flash 5 the 
code for the type was 8. This was changed to 9 in Flash 6 when the size of the 
index was increased to 16 bits to support the Table data structure which could
store up to 65536 strings.</td>
</tr>

<tr>
<td nowrap valign="top">index</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8 or 16</td>
<td>The index into the Table data structure for a particular string. In Flash 5
the Table data structure only supported 256 strings. The index field was increased
to 16 bits in Flash 6 to support Tables with up to 65536 strings.</td>
</tr>

</table>

<p>In the Macromedia Flash (SWF) File Format Specification all literals used in 
calculations are stored as strings. When performing a series of actions each time 
a literal value is used in a calculation it must be pushed onto the stack. Rather 
than repeatedly pushing the value explicitly using a Push action, all the 
literals are added to a table in the Flash Player's memory using the Table 
action. To retrieve a literal from the table a reference to an entry in the 
table is pushed onto the stack using a TableIndex. The reduces the number of 
bytes required to perform a given calculation when the values are used repeatedly.</p>

<p>As an example consider the code required to concatenate two strings:</p>

<pre>
ArrayList actions = new ArrayList();
...
// Create the table of literals
FSTable literals = new FSTable();
literals.add("abc");
literals.add("def");
actions.add(literals);
...
// Create references to the string literals
FSPush push = new FSPush();
push.add(new FSTableIndex(0));
push.add(new FSTableIndex(1));
actions.add(push);
...
// concatenate the strings
actions.add(new FSAction(FSAction.Add));
</pre>

<p>A Table can store up to 65536 (Flash 6 onwards) string literals. Using a 
table index rather than specifying the string literal explicitly reduces 
considerably the number of bytes required to represent a sequence of actions.</p>

<h2>History</h2>

<p>The string literal table was introduced in Flash 5. It was extended in Flash 
6 to support tables of up to 65536 strings.</p>
